package com.cmsr.springclond.redission;

import com.cmsr.springclond.SpringsProviderApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.concurrent.TimeUnit;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = SpringsProviderApplication.class)
public class test {
    @Autowired
    private RedissonClient redissonClient;

    @Test
    public void test1(){

        RLock rLock=redissonClient.getLock("a");
        try{
            rLock.lock(10, TimeUnit.SECONDS);
            System.out.println("1111");
        }catch(Exception e){
            System.out.println(e);
        }finally {
            rLock.unlock();
        }

    }


}
